#ifndef VECTOR2D_H_
#define VECTOR2D_H_

#include <iostream>
#include <boost/assert.hpp>

/**
 *  Designed to store pair of numbers (double) to describe position
 *  of models
 */

class Vector2d
{
public:
	///Public position params for easy access
	double x,y;
	Vector2d();
	Vector2d(double x, double y);
	Vector2d(const Vector2d & );

	/**
	 * Creates a vector which is a unit vector corresponding to
	 * given robot rotation - it is assumed that robot rotation
	 * equals 0 when robot is turned along Y axis, not X !
	 *
	 * @param robotRotation - angle (radians!)
	 */
	static Vector2d getRobotUnitVector(double robotRotation);

	/**
	 * Creates a vector which is a unit vector corresponding to
	 * given rotation.
	 *
	 * @param globalRotation - angle (radians!)
	 */
	static Vector2d getUnitVector(double globalRotation);

	~Vector2d();
	
	double length() const;
	/// Scales vector to have given length
	void setLength(double newLength);

	///Returns angle to given vector
	double angleTo(const Vector2d &) const;
	int signOfangleTo(const Vector2d & to) const;
	//iloczyn skalarny
	double scalarProduct(const Vector2d &)const;

	//rzutuje wybrany punkt na prosta Ax+By+C=0
	Vector2d projectionOn(double a, double b,double c) const;
	double distance(Vector2d to) const;

	///Calculates distance to line given by 2 points: start and end
	double distance(const Vector2d & start, const Vector2d & end) const;
	Vector2d & operator=(const Vector2d &);
	Vector2d  operator-(const Vector2d &)const;
	Vector2d operator-(const Vector2d &);
	Vector2d operator+(const Vector2d &) const;
	///Metoda pozwalająca na przeskalowanie wektora (mnożenie przez skalar).
	Vector2d operator*(double ) const;
	
	bool operator <(const Vector2d & v);
	
	///Zwracająca wektor bazowy obrócony o kąt angle (w radianach).
	Vector2d rotate(double angle);
	
	friend std::ostream & operator<<(std::ostream & os, const Vector2d & v );
};

#endif /*VECTOR2D_H_*/
